import os
from multiprocessing import Pool 


input_files = os.listdir("./13.tree_annotation_to_table")

output_dir = "./14.concept_circle"
os.makedirs(output_dir, exist_ok=True)

tree = "./16.menu_tree_to_dict_embedding.json"


def exec(annotation_table, tree, concept_parent_all, output_dir):
    cmd = f"python 14.generate_concept_circle.py -annotation_table {annotation_table} -tree {tree} -concept_parent_all {concept_parent_all} -output_dir {output_dir}"
    os.system(cmd)
    
tasks = []
for file in input_files:
    concept_tree = os.path.join("./12.tree_concept_parent",  file.split(".")[0] + ".json")
    annotation_table = os.path.join("./13.tree_annotation_to_table", file.split(".")[0] + ".xlsx")
    tasks.append((annotation_table, tree, concept_tree, output_dir))

# for i in tasks[0:2]:
#     exec(i[0], i[1], i[2], i[3])

with Pool(250) as pool:
    pool.starmap(exec, tasks)